<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //100%
    var dominantIndex = function(nums) {
        let max = Math.max(...nums);
        let index = nums.indexOf(max);
        nums.splice(index,1);
        let max2 = Math.max(...nums);
        return max>=2*max2?index:-1;
    };
    let nums = [3, 6, 1, 0];
    console.log(dominantIndex(nums));
    
</script>
</html>